package com.example.mytestdemo.text

import android.content.Context
import android.util.AttributeSet
import android.view.MotionEvent
import android.widget.ScrollView

/**
 * Created by QiuBin on 2021/8/25.
 * Describe: 禁止ScrollView滑动
 */
class NoScrollView @JvmOverloads constructor(
    context: Context, attrs: AttributeSet? = null
) : ScrollView(context, attrs) {
    var canScroll = false

    override fun onTouchEvent(ev: MotionEvent?): Boolean {
        return if (canScroll) {
            super.onTouchEvent(ev)
        } else {
            true
        }
    }
}